// ASSESSMENT CODE BELOW
function processAssessment()
{
	var total = 0;
	var score = 0;

	var answer1 = document.forms.assessment.question1;
	var answer2 = document.forms.assessment.question2;
	var answer3 = document.forms.assessment.question3;
	var answer4 = document.forms.assessment.question4;
	var answer5 = document.forms.assessment.question5;
	var answer6 = document.forms.assessment.question6;
	var answer7 = document.forms.assessment.question7;
	var answer8 = document.forms.assessment.question8;
	var answer9 = document.forms.assessment.question9;
	var answer10 = document.forms.assessment.question10;
	
	if( answer1[ 2 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer2[ 1 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer3[ 2 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer4[ 1 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer5[ 2 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer6[ 1 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer7[ 1 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer8[ 2 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer9[ 1 ].checked == true )
		{
			score = score + 10;
		}
	if ( answer10[ 2 ].checked == true )
		{
			score = score + 10;
		}

	
	if ( score >= 70 == true)
		{ 
			alert ( "You passed!");
			document.getElementById( "certificatelink" ).style.display = "inline";
		}
	else
		{ 
			alert ( "Sorry, you did not pass. Why don't you try again?");
		}
		parent.reportScores( score );
}


// Hide Assessment

function showAssessment()
{
	var ft = sessionStorage.getItem( "firstTime" );
	
	if ( ft == null )
	{
		sessionStorage.setItem( "firstTime", "1" );
		sessionStorage.setItem( "visitIntro", "0" );
		sessionStorage.setItem( "visitProfile", "0" );
		sessionStorage.setItem( "visitNutritionMyths", "0" );
		sessionStorage.setItem( "visitNutrition1", "0" );
		sessionStorage.setItem( "visitNutrition2", "0" );
		sessionStorage.setItem( "visitTargetHeartRate", "0" );
		sessionStorage.setItem( "visitExerciseMyths", "0" );
		sessionStorage.setItem( "visitExercise1", "0" );
		sessionStorage.setItem( "visitMassageMyths", "0" );
		sessionStorage.setItem( "visitMassage1", "0" );
		sessionStorage.setItem( "visitMassage2", "0" );
		sessionStorage.setItem( "passAssessment", "0" );
	}
}

function visitIntro()
{
	sessionStorage.setItem( "visitIntro", "1" );
	showAssessment();
}

function visitProfile()
{
	sessionStorage.setItem( "visitProfile", "1" );
	showAssessment();
}

function visitNutritionMyths()
{
	sessionStorage.setItem( "visitNutritionMyths", "1" );
	showAssessment();
}

function visitNutrition1()
{
	sessionStorage.setItem( "visitNutrition1", "1" );
	showAssessment();
}

function visitNutrition2()
{
	sessionStorage.setItem( "visitNutrition2", "1" );
	showAssessment();
}

function visitTargetHeartRate()
{
	sessionStorage.setItem( "visitTargetHeartRate", "1" );
	showAssessment();
}

function visitExerciseMyths()
{
	sessionStorage.setItem( "visitExerciseMyths", "1" );
	showAssessment();
}

function visitExercise1()
{
	sessionStorage.setItem( "visitExercise1", "1" );
	showAssessment();
}

function visitMassageMyths()
{
	sessionStorage.setItem( "visitMassageMyths", "1" );
	showAssessment();
}	

function visitMassage1()
{
	sessionStorage.setItem( "visitMassage1", "1" );
	showAssessment();
}

function visitMassage2()
{
	sessionStorage.setItem( "visitMassage2", "1" );
	showAssessment();
}

function passAssessment()
{
	var ft = sessionStorage.getItem( "finalassessment" );
	if ( score >= 70 )
	{
		document.getElementById( "certificatelink" ).className = "show";
	}
}

function showAssessment()
{
	var vi = sessionStorage.getItem( "visitIntro" );
	var vp2 = sessionStorage.getItem( "visitProfile" );
	var vp3 = sessionStorage.getItem( "visitNutritionMyths" );
	var vp4 = sessionStorage.getItem( "visitNutrition1" );
	var vp5 = sessionStorage.getItem( "visitNutrition2" );
	var vp6 = sessionStorage.getItem( "visitTargetHeartRate" );
	var vp7 = sessionStorage.getItem( "visitExerciseMyths" );
	var vp8 = sessionStorage.getItem( "visitExercise1" );
	var vp9 = sessionStorage.getItem( "visitMassageMyths" );
	var vp10 = sessionStorage.getItem( "visitMassage1" );
	var vp11 = sessionStorage.getItem( "visitMassage2" );
	
	if( vi == "1" && vp2 == "1" && vp3 == "1" && vp4 == "1" && vp5 == "1" && vp6 =="1" && vp7 == "1" && vp8 == "1" && vp9 == "1" && vp10 == "1" && vp11 == "1" ) 
	{
		document.getElementById( "assessmentlink" ).className = "show";
	}
}

 

function insertName()
{	
	var name = sesssionStorage.getItem( "wholename" );
	document.getElementById( "certificateName" ).innerHTML = "name";
}	